package org.cyb.demo.service.impl;

import org.cyb.demo.dao.ChapterMapper;
import org.cyb.demo.domain.Chapter;
import org.cyb.demo.domain.Course;
import org.cyb.demo.service.ChapterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("chapterService")
public class ChapterServiceImpl implements ChapterService {
    @Autowired
    ChapterMapper chapterMapper;

    @Override
    public int add(Chapter chapter, Course course) {
        return chapterMapper.insert(chapter,course);
    }

    @Override
    public void remove(Chapter chapter) {
        chapterMapper.delete(chapter);
    }

    @Override
    public void modify(Chapter chapter) {
        chapterMapper.update(chapter);
    }

    @Override
    public List<Chapter> find(Chapter chapter) {
        return chapterMapper.selectByName(chapter);
    }

    @Override
    public List<Chapter> findAll() {
        return chapterMapper.selectAll();
    }

    @Override
    public Chapter findOneById(Chapter chapter) {
        return chapterMapper.selectOneById(chapter);
    }
}
